import {debounce} from "@/common/utils";
import backTop from "@/components/content/backTop/backTop";

export const itemImgLoad = {
  data(){
    return {
      itemListListener: null
    }
  },
  mounted(){
    const refresh = debounce(this.$refs.scroll.refresh,500);
    this.itemListListener = () => refresh()
    this.$bus.$on('itemImgLoad',this.itemListListener)
  }
}

export const backTopMixin = {
  components:{
    backTop
  },
  data(){
    return {
      isShowBackTop: false,
    }
  },
  methods:{
    backClick(){
      this.$refs.scroll.scrollTo(0,0,100);
    },
    listenShowBackTop(position,showPosition = 1600){
      if(-position.y >= showPosition){
        this.isShowBackTop = true
      }else{
        this.isShowBackTop = false
      }
    }
  }
}
